{template header.html}
<script type="text/javascript">
$(function() {
	{if $result_error}
	dr_tips('{$result_error.msg}', 3);
	d_tips('{$result_error.error}', 0);
	{/if}
    //每隔5秒保存表单数据
    {if !$data.id && !$did}
    setInterval("dr_save_add_data()", 5000);
    {/if}
    // 加载草稿
    $("#dr_cgbox").mouseover(function(){
        $(".dr_cgbox").show();
    }).mouseout(function(){
        $(".dr_cgbox").hide();
    });
    // 删除草稿数据
    $(".dr_cgbox_delete").click(function(){
        var did = $(this).attr("did");
        var num = parseInt($("#dr_cg_nums").html());
        $.ajax({
            type: "POST",
            dataType:"json",
            url: memberpath+'index.php?c=api&m=ajax_delete_draft&sid={SITE_ID}&dir={APP_DIR}&did='+did,
            success: function(data) {
                if (data == did) {
                    $("#dr_cgbox_"+did).remove();
                    $("#dr_cg_nums").html(num - 1);
                } else {
                    dr_tips(data);
                }
            },
            error: function(HttpRequest, ajaxOptions, thrownError) { }
        });
    });
    $(".dr_cgbox_select").click(function(){
        var did = $(this).attr("did");
        window.location.href = '{$draft_url}&did='+did;
    });
    // 自动保存草稿
    {if $did}
        setInterval("dr_save_draft_data()", 5000);
    {/if}
});
function dr_sync(id, _this) {
    var tid = $("#dr_"+id).val();
    if (tid == 1) {
        $("#dr_"+id).val("0");
        $(_this).attr("src", "{MEMBER_URL}statics/OAuth/"+id+".gif");
    } else {
        $("#dr_"+id).val("1");
        $(_this).attr("src", "{MEMBER_URL}statics/OAuth/"+id+"_on.gif");
    }
}
// 动态保存草稿数据
function dr_save_draft_data() {
$.ajax({
    type: "POST",
    dataType:"json",
    url: memberpath+'index.php?c=api&m=ajax_save_draft&sid={SITE_ID}&dir={APP_DIR}&did={$did}',
    data: $("#myform").serialize(),
    success: function(data) { },
    error: function(HttpRequest, ajaxOptions, thrownError) { }
});
}
// 动态保存表单数据
function dr_save_add_data() {
    $.ajax({
        type: "POST",
        dataType:"json",
        url: memberpath+'index.php?c=api&m=ajax_save_add&dir={APP_DIR}_extend',
        data: $("#myform").serialize(),
        success: function(data) { },
        error: function(HttpRequest, ajaxOptions, thrownError) { }
    });
}
</script>
<div class="content clearfix">
	<div class="page_url">
    	<a href="{SITE_URL}">首页</a> <span>&gt;</span> <a href="{dr_member_url('home/index')}">会员中心</a> <span>&gt;</span> {$meta_name}
    </div>
    <div class="section_wp drbox" style="width:auto;float:none">
        <div class="section_title">
            <ul class="dr_member_cgbox">
                <li style="float:left;"><a href="javascript:;" class="cur">{lang('mod-37')}</a></li>
                {if $draft_list}
                <li class="cg li" id="dr_cgbox">
                    <a class="dr_cgbox_a">草稿（<span id="dr_cg_nums">{count($draft_list)}</span>）</a>
                    <fieldset class="dr_cgbox" style="display:none">
                        <div class="picList">
                            <ul class="cg_items" style="max-height: 400px;overflow-y: auto;">
                                {loop $draft_list $t}
                                <li id="dr_cgbox_{$t.id}">
                                    <a href="javascript:;" class="dr_cgbox_delete" did="{$t.id}" title="{lang('del')}"><img align="absmiddle" src="{SITE_URL}dayrui/statics/images/b_drop.png"></a>
                                    <span>{dr_date($t.inputtime)}</span>
                                    <a href="javascript:;" class="dr_cgbox_select" did="{$t.id}">{$t.name}</a>
                                </li>
                                {/loop}
                            </ul>
                        </div>
                    </fieldset>
                </li>
                {/if}
            </ul>
            <div class="cl"></div>
        </div>
        <div class="section_main">
            <form action="" id="myform" name="myform" method="post">
                <input name="action" id="dr_action" type="hidden" value="" />
                <table width="100%" class="table_form">
				{$myfield}
				<tr>
					<th width="160" style="border-bottom:none">&nbsp;</th>
					<td style="border-bottom:none;padding-top: 20px;">
                    	<div class="mbutton">
                            <button value="" onclick="$('#dr_action').val('draft')" type="submit" class="cgbox_bt">草稿</button>

                            <button value="" type="submit" class="submit_bt">提交</button>
                            {if !$data.id}
                            <label>将它同步至微博：</label>
                            <img src="{MEMBER_URL}statics/OAuth/qq_share.gif" onclick="{if $member.oauth.qq}dr_sync('qq_share',this){else}dr_confirm_url('您还没有绑定QQ账号呢，现在就去绑定吗？离开页面内容会消失', '{dr_member_url('account/oauth')}'){/if}" align="absmiddle" style="cursor:pointer" />
                            <input name="qq_share" id="dr_qq_share" type="hidden" value="0" />
                            &nbsp;
                            <img src="{MEMBER_URL}statics/OAuth/sina_share.gif" onclick="{if $member.oauth.sina}dr_sync('sina_share',this){else}dr_confirm_url('您还没有绑定新浪账号呢，现在就去绑定吗？离开页面内容会消失', '{dr_member_url('account/oauth')}'){/if}" align="absmiddle" style="cursor:pointer" />
                            <input name="sina_share" id="dr_sina_share" type="hidden" value="0" />
                            {/if}
                        </div>
                    </td>
				</tr>
				</table>
            </form>
        </div>
    </div>
</div>
{template footer.html}